<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<title>缺陷确认列表页面</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../lib/layui/css/layui.css" media="all">
<style>
    #tableWrap .layui-table-cell {
        height: auto;
    }
    #tableWrap .layui-table-box,
    #tableWrap .layui-table-body,
    #tableWrap .layui-table-cell {
        overflow: visible;
    }
    #layui-laypage-1 .layui-laypage-limits {
        display: none;
    }
</style>
</head>
<body>
<!--缺陷确认管理列表页面-->
<div style="margin-bottom: 5px;">

    <!--查询模块-->
    <form class="layui-form" style="padding-top:10px" >
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">任务编号</label>
                <div class="layui-input-inline">
                    <input type="tel"  name="inspectionTaskCode" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">线路编号</label>
                <div class="layui-input-inline">
                    <input type="tel"  name="lineCode" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">杆塔编号</label>
                <div class="layui-input-inline">
                    <input type="tel"  name="poleCode" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">发现人</label>
                <div class="layui-input-inline">
                    <input type="tel"  name="discovererName" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">缺陷类型</label>
                <div class="layui-input-inline">
                    <select name="bugType" id="bugType" lay-filter="bugType">
                        <option value=""></option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">缺陷级别</label>
                <div class="layui-input-inline">
                    <select name="bugLevel" class="bugLevel" id="bugLevel" lay-filter="bugLevel">
                        <option value=""></option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">发现时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="startDate" class="layui-input" id="startDate" placeholder="yyyy-MM-dd">
                </div>
                <label class="layui-form-label">到</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="endDate" id="endDate" placeholder="yyyy-MM-dd">
                </div>
            </div>
            <div class="layui-form-item layui-inline" >
                <button class="layui-btn" lay-submit="" lay-filter="search">查询</button>
            </div>
        </div>
    </form>

    <!--缺陷确认管理列表模块-->
    <table class="layui-table" lay-data="{width: 990,height:250, url:'/flaw/confirmList', page:true,limit:3, id:'test'}"
           lay-filter="demo">
        <thead>
        <tr>
            <th lay-data="{field:'psInspectiontaskMain', width:100,templet : function (data) {
                        return data.psInspectiontaskMain.inspectionTaskCode;}}">任务编号</th>
            <th lay-data="{field:'lineCode', width:100}">线路编号</th>
            <th lay-data="{field:'poleCode', width:100}">杆塔编号</th>
            <th lay-data="{field:'bugTypeName', width:100}">缺陷类型</th>
            <th lay-data="{field:'intactRate', width:100}">完好率%</th>
            <th lay-data="{field:'bugDesc', width:100}">缺陷描述</th>
            <th lay-data="{field:'discoverTime', width:180}">发现时间</th>
            <th lay-data="{field:'discovererName', width:100}">发现人员</th>
            <th lay-data="{fixed: 'right', width:100, align:'center', toolbar: '#barDemo'}">缺陷级别</th>
        </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="confirm">确认缺陷级别</a>
    </script>
</div>
<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script src="../js/jquery.min.js" charset="utf-8"></script>
<script>
    layui.use(['table', 'layer', 'form', 'laypage', 'laydate'], function () {
        var table = layui.table, //表格
            layer = layui.layer, //弹层
            form = layui.form, //form表单
            laydate = layui.laydate;
            // $(".layui-table-body, .layui-table-box, .layui-table-cell,.sel_scrq").css("overflow", "visible");
        //加载日期框
        laydate.render({
            elem: '#startDate'
        });
        laydate.render({
            elem: '#endDate'
        });
        //缺陷类型选择添加到下拉框中
       $.ajax({
            url: '/flaw/flawTypeList',
            dataType: 'json',
            type: 'get',
            success: function (data) {
                $.each(data, function (index, item) {
                    $('#bugType').append(new Option(item.configValueName, item.configValueId));// 下拉菜单里添加元素
                });
                layui.form.render("select");
            }
        });
        //缺陷级别选择添加到下拉框中
        $.ajax({
            url: '/flaw/bugLevelList',
            dataType: 'json',
            type: 'get',
            success: function (data) {
                $.each(data, function (index, item) {
                    $('.bugLevel').append(new Option(item.configValueName, item.configValueId));// 下拉菜单里添加元素
                });
                layui.form.render("select");
            }
        });

        //监听查询表单提交提交 lay-filter="search"
        form.on('submit(search)', function(data){
            var formData = data.field;
            var inspectionTaskCode = formData.inspectionTaskCode;
            var lineCode = formData.lineCode;
            var poleCode = formData.poleCode;
            var discovererName = formData.discovererName;
            var bugType = formData.bugType;
            var bugLevel = formData.bugLevel;
            var startDate = formData.startDate;
            var endDate = formData.endDate;
            url=formData.url;
            icon=formData.icon;
            parent_id=formData.parent_id;
            //执行重载
            table.reload('test', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {//这里传参  向后台
                    inspectionTaskCode: inspectionTaskCode,
                    lineCode: lineCode,
                    poleCode: poleCode,
                    discovererName: discovererName,
                    bugType: bugType,
                    bugLevel: bugLevel,
                    startDate: startDate,
                    endDate: endDate
                    //可传多个参数到后台...  ，分隔
                }
                , url: '/flaw/confirmList'//后台做模糊搜索接口路径
                , method: 'post'
            });
            return false;//false：阻止表单跳转  true：表单跳转
        });

        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            console.log("id:"+data.id)
            if(obj.event === 'confirm'){
                layer.open({
                    type: 2,
                    content: ["/flaw/flaw_confirm_save?id="+data.id],   //添加页，后台controller转发到指定页
                    area: ["400px", "300px"],
                    title: ['确认级别'],
                    fixed: false,
                    //maxmin: true,
                    shadeClose: true,
                    end: function () {  //刷新页面
                        table.reload('test', {
                            page: {
                                curr: 1 //重新从第 1 页开始
                            },
                            url: '/flaw/confirmList', //后台做模糊搜索接口路径
                            method: 'post'
                        });
                    }
                })
            }
        });

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>

</body>
</html>